import requests
from jsonpath import jsonpath

from test_pom.test4_八爪云接口自动化测试.utils.log_utils import logger


class BaseApi:
    __REQ = {
        "url": "http://api.wxorder.taover.com/login",
        "method": "post",
        "json": {
            "username": "17611219803",
            "password": "Ceba_17611219803",
            "code": ""}
    }
    def send_api(self, req):
        res = requests.request(**req)
        logger.info("请求响应结果为：{}".format(res.json()))
        return res

    def get_token(self):
        res = self.send_api(self.__REQ)
        token = jsonpath(res.json(), "$..token")[0]
        return token


if __name__ == '__main__':
    print(type(BaseApi().get_token()),BaseApi().get_token())